package com.yuma.threads;

// 实现了Runnable接口的类是线程类吗？ 不是线程类，具备线程行为！
class RWindow implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + "窗口卖出了第" + (i+1) + "张票");
        }
    }
}

public class RunnableDemo {
    public static void main(String[] args) {
        RWindow rw = new RWindow();

        Thread t1 = new Thread(rw, "A");

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println(Thread.currentThread().getName() + "窗口卖出了第" + (i+1) + "张票");
                }
            }
        },"B");

        Thread t3 = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName() + "窗口卖出了第" + (i+1) + "张票");
            }
        },"C");

        t1.start();
        t2.start();
        t3.start();
    }
}
